﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using SmartSpace;
using DynamicChart.Web.Models;

namespace DynamicChart.Web
{
    /// <summary>
    /// Summary description for ManagementWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ManagementWebService : System.Web.Services.WebService
    {
        [WebMethod]
        public ListResult<InternalDataSource> GetInternalDataSource()
        {
            DynamicChartService service = new DynamicChartService();
            return new ListResult<InternalDataSource>(service.GetInternalDataSources());
        }

        [WebMethod]
        public ServiceResult SaveInternalDataSource(InternalDataSource dataSource)
        {
            DynamicChartService service = new DynamicChartService();
            if (service.SaveInternalDataSource(dataSource))
            {
                return new ServiceResult(true, "保存成功!");
            }
            return new ServiceResult(false, "保存失败!");
        }

        [WebMethod]
        public ServiceResult DeleteInternalDataSource(InternalDataSource dataSource)
        {
            DynamicChartService service = new DynamicChartService();
            if (service.DeleteInternalDataSource(dataSource))
            {
                return new ServiceResult(true, "删除成功!");
            }
            return new ServiceResult(false, "删除失败!");
        }
    }
}
